package com.skytech.tax.customsdatawarehouse.electronicport.proceedspayment.importpayment.resource;

import com.skytech.tax.customsdatawarehouse.electronicport.proceedspayment.importpayment.domain.service.ImportPaymentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Lianhong
 * @since 2021/11/19
 */
@RestController
@RequestMapping("/e-port/import-payment")
public class ImportPaymentResource {

    @Resource
    private ImportPaymentService importPaymentService;


    /**
     * 保存进口付汇
     *
     * @param importPayment 进口付汇
     */
    @PostMapping
    public String saveImportPayment(@RequestBody String importPayment) {
        return importPaymentService.save(importPayment);
    }

    /**
     * 查询进口付汇
     *
     * @param entryId 报关单号
     */
    @GetMapping("{entryId}")
    public String details(@PathVariable String entryId) {
        return importPaymentService.details(entryId);
    }

    /**
     * 删除进口付汇
     *
     * @param entryId 报关单号
     */
    @DeleteMapping("{entryId}")
    public void remove(@PathVariable String entryId) {
        importPaymentService.remove(entryId);
    }

    /**
     * 判断是否存在进口付汇
     *
     * @return entryId-01,entryId-02,...
     */
    @PostMapping("exists")
    public String existsImportPayments(@RequestBody List<String> entryIds) {
        return importPaymentService.existsImportPayments(entryIds);
    }


    /**
     * 判断是否存在进口付汇
     *
     * @param entryId 报关单号
     * @return 是否存在
     */
    @GetMapping("{entryId}/exists")
    public boolean existsImportPayment(@PathVariable String entryId) {
        return importPaymentService.exists(entryId);
    }


    /**
     * 查询进口付汇文件名
     *
     * @param entryId 出口报关单号
     * @return 阿里云存储文件名
     */
    @GetMapping("{entryId}/file")
    public String importPaymentFile(@PathVariable String entryId) {
        return importPaymentService.importPaymentFile(entryId);
    }

    /**
     * 保存进口付汇文件名
     *
     * @param entryId   出口报关单号
     * @param storedFile 存储文件名称
     */
    @PostMapping("{entryId}/file")
    public void saveImportPaymentFile(@PathVariable String entryId, @RequestBody String storedFile) {
        importPaymentService.saveImportPaymentFile(entryId, storedFile);
    }

    /**
     * 出口进口付汇是否已存储
     *
     * @param entryId 出口报关单号
     */
    @GetMapping("{entryId}/file/stored")
    public boolean importPaymentFileStored(@PathVariable String entryId) {
        return importPaymentService.importPaymentFileStored(entryId);
    }

}
